package com.talkology.pilot.student.controller;

import com.talkology.pilot.database.model.User;
import com.talkology.pilot.student.service.IStudentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/studentUser")
public class StudentUserController {
    @Autowired
    private IStudentUserService service;


    @RequestMapping(value = "/all", method= RequestMethod.GET)
    @ResponseBody
    public List<User> getTeacherByFilter(User name) {
        return service.getAllByFilter(name);
    }

    @RequestMapping(value = "/add", method= RequestMethod.PUT)
    @ResponseBody
    public void addTeacherInfo(@RequestBody User record) {
        service.add(record);
    }

    @RequestMapping(value = "/update", method= RequestMethod.PUT)
    @ResponseBody
    public void updateTeacherInfo(@RequestBody User record) {
        service.edit(record);
    }

    @RequestMapping(value = "/delete", method= RequestMethod.DELETE)
    @ResponseBody
    public void deleteTeacherInfo(@RequestParam(value = "index", required = false) Long index) {
        service.delete(index);
    }
}
